package com.gxuwz.medical.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;

import com.gxuwz.medical.database.DbUtil;
import com.gxuwz.medical.domain.baoxiao.BaoXiao;
import com.gxuwz.medical.vo.PageBean;

public class BaoXiaoDao extends GenericDao<BaoXiao> {

	@Override
	public BaoXiao handle(ResultSet rs) throws SQLException {
		BaoXiao bx = new BaoXiao();
		bx.setBaoxiaono(rs.getString("baoxiaono"));
		bx.setIdcard(rs.getString("idcard"));
		bx.setIllname(rs.getString("illname"));
		bx.setCureno(rs.getString("cureno"));
		bx.setCuremoney(rs.getDouble("curemoney"));
		bx.setCuretime(rs.getTimestamp("curetime"));
		bx.setPremoney(rs.getDouble("premoney"));
		bx.setRelmoney(rs.getDouble("relmoney"));
		bx.setBaoxiaotime(rs.getTimestamp("baoxiaotime"));
		return bx;
	}

	public void add(BaoXiao bx) throws SQLException {
		DbUtil db = new DbUtil();
		String sql = "insert into baoxiao values('" + bx.getBaoxiaono() + "','"
				+ bx.getIdcard() + "','" + bx.getIllname() + "','"
				+ bx.getCureno() + "','" + bx.getCuremoney() + "','"
				+ new java.sql.Timestamp(bx.getCuretime().getTime()) + "','"
				+ bx.getPremoney() + "','" + bx.getRelmoney() + "','"
				+ new java.sql.Timestamp(new Date().getTime()) + "')";
		db.executeUpdate(sql);
	}

	public PageBean queryAll(int page, int size) throws SQLException {
		String sql = "select * from baoxiao";
		return super.queryAll(sql, null, page, size);
	}

}
